<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="./resources/style.css">
        <script type="module">
            import { log, stringify, currentNetwork } from './resources/utils.js';

            import * as kaspa from '../../web/kaspa-rpc/kaspa.js';
            let { Resolver, RpcClient, Encoding } = kaspa;

            (async () => {
                await kaspa.default('../../web/kaspa-rpc/kaspa_bg.wasm');

                let networkId = currentNetwork();
                log(`Connecting to Kaspa network...`);
                log(`Selected network is ${networkId}...`);
                
                const rpc = new RpcClient({
                    resolver : new Resolver(),
                    networkId,
                });

                await rpc.connect();
                log("Connected to", rpc.url);
                
                log("GetBlockDagInfo request...");
                const info = await rpc.getBlockDagInfo();
                log("GetBlockDagInfo response:", info);

                log("Disconnected...");
                await rpc.disconnect();
            })();

        </script>
    </head>
    <body></body>
</html>